<?php 
class configuracoesController extends CController{
    
    public $model_name = 'admin/configuracao';
    public function index(){
        $item = $this->model->selecionar_plugin_config(CURRENT_MODULE);
        $this->registerVar("configuracao", $item);
        $this->genTags("Gestão de configuração");
        $this->display(LINK . '/index');
    }
    
    public function configure(){
        $plugin = array_shift($this->vars);
        $file   = array_shift($this->vars);
        if(!empty ($_POST)) $this->model->editar_plugin($plugin, $file, $_POST);
        $this->registerVar("dados", $this->model->get_config_by_plugin($plugin, $file));
        $this->setVars($this->model->getMessages());
        $this->display('admin/configuracao/plugin_config');
    }
    
    public function rodape(){

        $this->LoadModel('admin/configuracao', 'md');
        $conffile = 'site';
        $this->md->setConfigType('Config');
        if(!$this->md->hasConfigurationFile($conffile)) Redirect (LINK);
        if(!empty ($_POST)) $this->md->editar($conffile, $_POST);
        
        $this->genTags("Arquivo $conffile.php");
        $this->registerVar("cfile", $conffile);
        $this->registerVar("dados", $this->md->getConf($conffile));
        $this->setVars($this->md->getMessages());
        $this->display('admin/configuracao/configure');
        //$this->display($this->model_name .'/configure');
    }
    
    public function ajuda(){
        $this->display(LINK.'/ajuda');
    }
}
?>